package com.example.redissontest.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @ClassName RedissonConfig
 * @Description
 * @Author huyingliang
 * @Date 2024/1/4 15:48
 */
@Configuration
public class RedissonConfig {

    @Value("${spring.redisson.host}")
    private String redissonHost;

    /*redisson配置*/
    @Bean
    RedissonClient redissonTemplate() throws IOException {
        Config config = new Config();
        /*设置字符格式*/
        config.setCodec(new org.redisson.client.codec.StringCodec());
        config.useSingleServer().setAddress(redissonHost);
        return Redisson.create(config);
    }


}
